
//TODO a(37)
function a37(module, exports, a) {
    function i(e) {
        this.fullScreen = e
    }

    var s = a(38), r = a(39), n = a(40), o = a(41), l = a(21), d = a(2), h = a(3);
    h.extend(i, s);
    var c = {
        init: function () {
            this.mms = new r, this.gslb = new n, this.history = new o, this.ad = null, this.playerData = this.manager.playerData, this.mmsData = null, this.mmsRetryTime = 0, this.gslbUrls = null, this.gslbUrlsIndex = 0, this.waitingTime = null, this.isFirstPlay = !0, this.curDefi = 0, this.manager.register(this.mms),
                this.manager.register(this.gslb), this.manager.register(this.history), this.manager.evt.on("vjs_mmsSucc", this.onMmsSucc, this), this.manager.evt.on("vjs_gslbSuccess", this.onGslbSucc, this), this.manager.evt.on("vjs_gslbFail", this.onGslbFail, this), this.manager.evt.on(l.EVENT.PLAYER_COMMAND, this.onPlayerCommand, this), this.manager.evt.on("vjs_preparPlay", this.onPreparPlay, this), this.manager.evt.on("vjs_startPlay", this.onStartPlay, this), this.manager.evt.on("vjs_sendCV", this.sendCV, this), this.manager.evt.on("vjs_p2pUrlSucc", this.onP2pUrlSucc, this), this.manager.listener.on(l.PLAY_STATE, function (e, t) {
                if ("init" == t) this.ad && this.ad.destoryAd(), this.manager.evt.off("vjs_loadstart", this.onLoadstart, this), this.manager.pingback.stopHeartRecord(), this.changeTrylook("none", 0), this.mmsData = null, this.mmsRetryTime = 0, this.gslbUrls = null, this.gslbUrlsIndex = 0, this.isFirstPlay = !0, this.manager.curVideo.release(); else if ("ended" == t) this.isFirstPlay = !0, this.manager.pingback.stopHeartRecord(), this.manager.pingback.sendPlayAction("end"), this.manager.evt.trigger(l.EVENT.PLAYER_CALLBACK, "PLAYER_VIDEO_COMPLETE", {
                    continuePlay: !0,
                    fullscreen: 0 != this.manager.listener.get(l.FULLSCREEN_STATE),
                    id: this.playerData.vinfo.vid,
                    nextvid: this.playerData.vinfo.nextvid,
                    recommendvideo: 0
                }); else if ("play" == t)if (this.isFirstPlay) {
                    if (this.isFirstPlay = !1, this.playerData.config.Barrage && this.playerData.config.hideBarrage) {
                        var a = {};
                        a.alphaBr = localStorage.getItem("alphaBr") ? localStorage.getItem("alphaBr") : 100, a.densityBr = localStorage.getItem("densityBr") ? localStorage.getItem("densityBr") : 2, a.banRoll = localStorage.getItem("banRoll") ? localStorage.getItem("banRoll") : 1, a.banBottom = localStorage.getItem("banBottom") ? localStorage.getItem("banBottom") : 1, a.banTop = localStorage.getItem("banTop") ? localStorage.getItem("banTop") : 1;
                        var i = localStorage.getItem("barrgeState") ? localStorage.getItem("barrgeState") : "true";
                        this.manager.evt.trigger(l.EVENT.PLAYER_CALLBACK, "videoStart", {
                            barrageJs: "true" == i ? 1 : 0,
                            barrageSetting: a
                        })
                    }
                    this.manager.evt.trigger(l.EVENT.PLAYER_CALLBACK, "PLAYER_VIDEO_PLAY", {id: this.playerData.vinfo.vid})
                } else this.manager.evt.trigger(l.EVENT.PLAYER_CALLBACK, "PLAYER_VIDEO_RESUME", {id: this.playerData.vinfo.vid}); else"pause" == t && "MPlayer" == this.playerData.pname && this.manager.evt.trigger(l.EVENT.PLAYER_CALLBACK, "PLAYER_VIDEO_PAUSE", {id: this.playerData.vinfo.vid});
                this.manager.log.pushLog("stateChange: " + t)
            }, this), this.manager.listener.on(l.IS_AD, function (e, t) {
                this.manager.log.pushLog("IS_AD:" + t), t ? this.manager.curVideo = this.ad.adVideo : this.manager.curVideo = this.manager.coreVideo
            }, this), this.manager.evt.on("vjs_play vjs_pause vjs_ended vjs_seeking vjs_waiting vjs_playing vjs_cancellation vjs_error", this.onVideoEvent, this), this.manager.listener.set(l.FULLSCREEN_STATE, 0), this.lanFit = h.bind(this.manager.lanFit.fit, this.manager.lanFit), this.startPlayProcesses()
        }, startPlayProcesses: function (e) {
            this.manager.curVideo.pause(), setTimeout(h.bind(function () {
                e ? this.mmsRetryTime++ : this.manager.listener.set(l.PLAY_STATE, "init"), this.mms.getMms()
            }, this), 0)
        }, onPlayerCommand: function (e) {
            var t = e.args[0];
            switch (this.manager.log.pushLog("playerCommand: " + t + ";args: " + h.JSONTOStr(e.args[1])), t) {
                case"play":
                    this.manager.curVideo.play();
                    break;
                case"pause":
                    this.manager.curVideo.pause();
                    break;
                case"replay":
                    this.manager.curVideo.replay();
                    break;
                case"seek":
                    var a = e.args[1];
                    if ("none" != this.playerData.tryLookType && this.checkTryLook(a))return;
                    this.manager.curVideo.seek(a), this.manager.evt.trigger(l.EVENT.PLAYER_CALLBACK, "PLAYER_SEEK", {
                        id: this.playerData.vinfo.vid,
                        time: a
                    });
                    break;
                case"changeDefi":
                    var i = e.args[1];
                    "init" != this.manager.listener.get(l.PLAY_STATE) && this.history.flush(this.manager.curVideo.getCurrentTime(), !0), this.manager.listener.set(l.PLAY_STATE, "changeDefi"), this.playVideo(i);
                    break;
                case"playNext":
                    var s = Boolean(e.args[1]);
                    this.manager.evt.trigger(l.EVENT.PLAYER_CALLBACK, "PLAYER_PLAY_NEXT", {
                        id: this.playerData.vinfo.vid,
                        nextvid: this.playerData.vinfo.nextvid,
                        fullscreen: !1,
                        active: s
                    });
                    break;
                case"reload":
                    this.startPlayProcesses();
                    break;
                case"changFullScreen":
                    var r = e.args[1], n = e.args[2];
                    2 != r ? this.manager.evt.trigger(l.EVENT.PLAYER_CALLBACK, "CHANGE_FULLSCREEN", {
                            flag: r,
                            isActiveBehavior: n
                        }) : this.fullScreen.changeFullScreen({type: "system", targetState: 2})
            }
        }, onVideoEvent: function (e) {
            var t = e.type, a = "";
            switch (t) {
                case"vjs_play":
                    a = "play";
                    break;
                case"vjs_pause":
                    a = "pause";
                    break;
                case"vjs_ended":
                    if ("none" != this.playerData.tryLookType)return;
                    a = "ended";
                    break;
                case"vjs_seeking":
                    a = "seeking";
                    break;
                case"vjs_waiting":
                    this.waitingTime = h.now();
                    break;
                case"vjs_playing":
                    this.waitingTime && (this.manager.pingback.sendPlayAction("block", {ut: h.now() - this.waitingTime}), this.waitingTime = null);
                    break;
                case"vjs_cancellation":
                    this.mmsRetryTime++, this.mms.getMms();
                    break;
                case"vjs_error":
                    if ("" == d.supportM3U8 && !d.forceMp4)return this.manager.log.pushLog("m3u8 fail.turn to mp4"), h.setCookie("vjs-supportM3U8", "0", {expires: 7}), d.supportM3U8 = "0", this.mmsRetryTime++, void this.mms.getMms();
                    var i = this.gslbUrls[this.gslbUrlsIndex++];
                    i ? this.manager.curVideo.setSrc(i) : ("ios" == this.playerData.videoType ? this.sendError(l.ERROR_CODE.URL_NOT_SUPPORT_M3U8) : this.sendError(l.ERROR_CODE.URL_NOT_SUPPORT_MP4), this.manager.log.pushLog("videoSrc: " + this.manager.coreVideo.getSrc()), this.manager.evt.trigger(l.EVENT.PLAYER_CALLBACK, "PLAYER_VIDEO_PAUSE"))
            }
            a && this.manager.listener.set(l.PLAY_STATE, a)
        }, onMmsSucc: function (e) {
            this.mmsData = e.args[0];
            var t = {350: 1, 1000: 2, 1300: 3, "720p": 4};
            this.curDefi = t[this.mmsData.curVType], this.playerData.vinfo.curVtype = this.mmsData.movieVO[this.curDefi].vtype, this.mmsRetryTime < 1 ? (h.merge(this.playerData.vinfo, this.mmsData.vinfo), this.manager.log.pushLog("vinfo: " + h.JSONTOStr(this.playerData.vinfo)), this.manager.evt.trigger("vjs_vinfoReady"), this.manager.log.pushLog("vjs_vinfoReady"), this.manager.evt.trigger("vjs_setPoster", this.playerData.flashVar.picStartUrl || this.playerData.vinfo.poster), this.manager.evt.trigger("vjs_initDefiList", this.mmsData.movieVO),
                this.gslb.setMovieVO(this.mmsData.movieVO), !this.mmsData.userInfo && this.playerData.validateInfo.ssouid ? this.manager.user.getUserInfo(h.bind(this.onUserInfoSuccess, this)) : (this.manager.listener.set(l.USER_INFO, this.mmsData.userInfo), this.onUserInfoSuccess())) :
                (this.gslb.setMovieVO(this.mmsData.movieVO), this.playVideo())
        }, onUserInfoSuccess: function () {
            this.manager.evt.trigger(l.EVENT.PLAYER_CALLBACK, "PLAYER_INIT", {id: this.playerData.vinfo.vid}), this.manager.log.pushLog("上报 vv"), this.manager.pingback.sendPlayAction("init", {
                cdev: "-",
                caid: "-"
            }), this.checkVideoAuth() || (this.manager.log.pushLog("trylooktype====" + this.playerData.tryLookType + "===time===" + this.playerData.tryLookTime), "none" != this.playerData.tryLookType && (this.manager.log.pushLog("vjs_durationChange vinfo====" + this.playerData.vinfo.gdur), this.manager.evt.trigger("vjs_durationChange", this.playerData.vinfo.gdur)), this.history.initData(h.bind(this.onHistorySucc, this)))
        }, onHistorySucc: function () {
            if (this.manager.listener.set(l.IS_AD, !1), this.ad)try {
                this.manager.listener.set(l.IS_AD, !0), this.ad.refreshAd()
            } catch (e) {
                this.manager.log.pushLog("ad error:" + e.toString()), this.playVideo()
            } else {
                var t = a(43);
                if (t)try {
                    this.manager.evt.on("vjs_adEnded", function () {
                        this.playVideo()
                    }, this), this.ad = new t(this.manager.coreVideo.baseVideo), this.manager.register(this.ad), this.manager.listener.set(l.IS_AD, !0), this.ad.refreshAd()
                } catch (e) {
                    this.manager.log.pushLog("ad error:" + e.toString()), this.playVideo()
                } else this.playVideo()
            }
        }, onGslbSucc: function (e) {
            this.manager.pingback.sendPlayAction("gslb", {
                ut: e.args[2].responseTime,
                ry: e.args[2].retryCount
            }), this.mmsRetryTime = 0, this.curDefi = e.args[1], this.manager.evt.trigger("vjs_videoRateChanged", this.curDefi), this.manager.evt.one("vjs_loadstart", this.onLoadstart, this), this.gslbUrls = e.args[0], this.gslbUrlsIndex = 0;
            var t = this.gslbUrls[this.gslbUrlsIndex++];
            this.manager.curVideo.setSrc(t)
        }, onGslbFail: function () {
            this.mmsRetryTime < 1 ? (this.mmsRetryTime++, this.mms.getMms()) : this.sendError(l.ERROR_CODE.GSLB_ERROR)
        }, onP2pUrlSucc: function (e) {
            this.curDefi = e.args[1], this.manager.evt.trigger("vjs_videoRateChanged", this.curDefi), this.manager.evt.one("vjs_loadstart", this.onLoadstart, this);
            var t = e.args[0];
            this.manager.curVideo.setSrc(t)
        }, checkVideoAuth: function () {
            if (1 == this.playerData.vinfo.authtype)return this.manager.evt.trigger("vjs_showPopTip", "authBan"), !0;
            if (2 == this.playerData.vinfo.authtype)return this.manager.evt.trigger("vjs_showPopTip", "vikiban"), !0;
            if (this.playerData.vinfo.firstlook)return this.manager.evt.trigger("vjs_showPopTip", "firstLook"), this.manager.evt.trigger(l.EVENT.PLAYER_CALLBACK, "PLAYER_FIRSTLOOK", {
                htime: 0,
                isH5: !0
            }), !0;
            if (this.playerData.vinfo.ispay) {
                var e = this.manager.listener.get(l.USER_INFO), t = this.playerData.validateInfo || {};
                if (e && "1" == t.isForbidden)return this.sendError(l.ERROR_CODE.USER_ABNORMAL), !0;
                if (!e || 1 != t.status) {
                    if (0 == this.playerData.vinfo.payTrylookTime) {
                        var a = e ? "payLoginMember" : "paynotLoginMember";
                        return this.manager.evt.trigger("vjs_showPopTip", a), this.manager.evt.trigger(l.EVENT.PLAYER_CALLBACK, "displayTrylook", {
                            trylookTime: 0,
                            userInfo: e,
                            type: a
                        }), !0
                    }
                    this.changeTrylook("vip", this.playerData.vinfo.payTrylookTime)
                }
                return !1
            }
            var a, i = this.playerData.config.splatId, s = this.playerData.vinfo, r = s.gdur, n = 0;
            if (s.appGuideTime > 0) n = s.appGuideTime, a = "flashvar"; else if (s.cutoff_p && s.cutoff_p.length > 0)for (var o = 0, d = s.cutoff_p.length; o < d; o++)if (i == s.cutoff_p[o]) {
                n = s.cutoff_t, a = "mms";
                break
            }
            return n > 0 && r > 60 * n && (this.changeTrylook("appGuide", n), this.manager.evt.trigger(l.EVENT.PLAYER_CALLBACK, "APP_GUIDE", {
                type: a,
                cutoffTime: n
            })), !1
        }, playVideo: function (e) {
            this.manager.listener.get(l.IS_AD) && this.manager.listener.set(l.IS_AD, !1);
            var t, a = this.mmsData.movieVO;
            if (e && a[e]) t = !0; else {
                t = !1;
                var i = this.curDefi || this.playerData.config.defi;
                i && a[i] ? e = i : a[2] ? e = "2" : a[1] ? e = "1" : a[3] && (e = "3")
            }
            this.curDefi = e, this.manager.log.pushLog("plavVideo Defi: " + e), this.playerData.vinfo.curVtype = a[e].vtype,
                this.gslb.getGslb(e, t)
        }, onPreparPlay: function () {
            this.playerData.config.isAutoPlay && this.manager.curVideo.play(), this.playerData.config.isAutoPlay = !0
        }, onStartPlay: function () {
            if (!this.manager.listener.get(l.IS_AD)) {
                var e = this.history.getRecords(), t = this.playerData.flashVar.htime || this.playerData.urlParams.htime;
                t = Math.max(0, t), t = t >= this.playerData.vinfo.gdur ? 0 : t, "changeDefi" == this.manager.listener.get(l.PLAY_STATE) ? this.manager.evt.trigger(l.EVENT.PLAYER_COMMAND, "seek", e) : this.playerData.config.historyPlay || "none" != this.playerData.tryLookType || (t ? (this.playerData.flashVar.htime = this.playerData.urlParams.htime = 0, this.manager.evt.trigger(l.EVENT.PLAYER_COMMAND, "seek", t)) : e && e > 30 && e < this.playerData.vinfo.gdur - 15 && this.manager.evt.trigger(l.EVENT.PLAYER_COMMAND, "seek", e)), "vip" == this.playerData.tryLookType ? this.manager.evt.trigger("showTip", "trylook") : "appGuide" == this.playerData.tryLookType && this.manager.evt.trigger("showTip", "appGuide")
            }
        }, sendCV: function () {
            this.manager.log.pushLog("上报 cv");
            var e = this.playerData.vinfo.ispay ? "none" != this.playerData.tryLookType ? 1 : 2 : 0;
            this.manager.pingback.sendPlayAction("play", {
                prl: 1,
                pay: e,
                joint: this.playerData.hasAD ? 1 : 0
            }), this.manager.pingback.sendComStore(), this.manager.pingback.startHeartRecord(), "ios" != this.playerData.videoType || this.playerData.config.supportP2P || (h.setCookie("vjs-supportM3U8", "1", {expires: 7}), d.supportM3U8 = "1")
        }, changeTrylook: function (e, t) {
            this.manager.log.pushLog("changeTrylook: " + e + "==" + t), this.playerData.tryLookType = e, this.playerData.tryLookTime = t, "none" != e ? this.manager.evt.on("vjs_timeupdate", this.checkTryLook, this) : this.manager.evt.off("vjs_timeupdate", this.checkTryLook, this)
        }, checkTryLook: function (e) {
            e = isNaN(e) ? this.manager.curVideo.getCurrentTime() : e;
            var t = this.lanFit;
            if (e >= 60 * this.playerData.tryLookTime) {
                if ("vip" == this.playerData.tryLookType) {
                    var a, i = this.manager.listener.get(l.USER_INFO), s = this.playerData.validateInfo;
                    if (i)if (!s.vodInfo.video || "0" != s.vodInfo.video.chargeType && "1" != s.vodInfo.video.chargeType) {
                        a = "openGlobalMember";
                        var r = s.player_member && s.player_member[0] ? s.player_member[0].name : t("会员");
                        this.manager.evt.trigger("vjs_showPopTip", "openGlobalMember", r)
                    } else s.size > 0 ? (a = "useTicket", this.manager.evt.trigger("vjs_showPopTip", "useTicket", s.size)) : (a = "noMoreTicket", this.manager.evt.trigger("vjs_showPopTip", "noMoreTicket", s.size)); else a = "loginMember", this.manager.evt.trigger("vjs_showPopTip", "loginMember");
                    this.manager.evt.trigger(l.EVENT.PLAYER_CALLBACK, "displayTrylook", {
                        trylookTime: this.playerData.tryLookTime,
                        userInfo: i,
                        vipInfo: s.player_member,
                        type: a
                    })
                } else"appGuide" == this.playerData.tryLookType && (this.manager.evt.trigger("vjs_showPopTip", "appGuideEnd"), this.manager.evt.trigger(l.EVENT.PLAYER_CALLBACK, "appGuideEnd"));
                return this.manager.evt.off("vjs_timeupdate", this.checkTryLook, this), 1
            }
            return 0
        }, onLoadstart: function () {
            this.manager.pingback.sendPlayAction("cload")
        }
    };
    h.merge(i.prototype, c), module.exports = i
}
